package br.com.localfloripa.dao;

import java.util.List;

import javax.inject.Named;
import javax.persistence.Query;

import org.springframework.context.annotation.Scope;

import br.com.localfloripa.entities.SubCategoria;

@Named("subCategoriaDao")
@Scope("singleton")
public class SubCategoriaDao extends DaoManager<SubCategoriaDao> {

	public SubCategoria findById(Long idSubCategoria) throws Exception {
		return em.find(SubCategoria.class, idSubCategoria);
	}
	
	public List<SubCategoria> listSubCategoriasOrdemNome() throws Exception {
		Query query = em.createQuery("SELECT s FROM SubCategoria s WHERE s.ativo IS TRUE ORDER BY s.nome");
		return query.getResultList();
	}
	
}
